﻿/*
Copyright (c) 2007-2011 William POTTIER - AllProgrammic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

using NetAccess.Message;

namespace NetAccess.Server
{
    /// <summary>
    /// Abstract class for server layer
    /// </summary>
    /// <remarks></remarks>
    public abstract class BaseServerLayer
    {
        #region Properties
        /// <summary>
        /// Gets or sets the configuration.
        /// </summary>
        /// <value>The configuration.</value>
        /// <remarks></remarks>
        public abstract ServerConfiguration Configuration { get; protected set; }
        #endregion

        #region Methods
        internal abstract void ClientConnect(BaseServerConnexion connexion);

        /// <summary>
        /// Raises on client disconnected.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <remarks></remarks>
        internal abstract void OnClientDisconnected(BaseServerConnexion client);

        /// <summary>
        /// Broadcast a message to all client on the server except this one
        /// </summary>
        /// <param name="exceptConnexion"></param>
        /// <param name="message"></param>
        /// <param name="crypt"></param>
        internal abstract void InternalBroadcast(InternalMessage message, bool crypt = false,
                                                 BaseServerConnexion exceptConnexion = null);

        internal abstract void InternalBroadcastRoom(int roomIdentifier, InternalMessage message, bool crypt = false,
                                                     BaseServerConnexion exceptConnexion = null);

        #region Rooms Management
        internal abstract void InternalCreateRoom(int roomIdentifier);

        internal abstract void InternalJoinRoom(int roomIdentifier, BaseServerConnexion connexion);

        internal abstract void InternalRemoveFromRoom(int roomIdentifier, BaseServerConnexion connexion);

        internal abstract void InternalDeleteRoom(int roomIdentifier);
        #endregion
        #endregion
    }
}
